<style>
    #tag_ids2  span.tips {
        top: 0 !important;
    }
</style>
<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
    <div class="layui-card-body">

        <div class="layui-form-item">
            <label class="layui-form-label">店员编号</label>
            <div class="layui-input-block">
                <input name="number" value='{$vo.number|default=""}' required placeholder="请输入店员编号" class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">店员名称</label>
            <div class="layui-input-block">
                <input name="name" value='{$vo.name|default=""}' required placeholder="请输入店员名称"
                       class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <input type="radio" name="sex" value="1" title="男" {if !isset($vo.sex)} checked{/if} {if isset($vo.sex)
                && $vo.sex==1 }checked{/if}>
                <input type="radio" name="sex" value="2" title="女" {if isset($vo.sex) && $vo.sex==2 }checked{/if}>
                <p class="help-block"></p>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">头像</label>
            <div class="layui-input-block">
                <div class="layui-upload">
                    {if empty($vo.portrait)}
                    <button type="button" class="layui-btn" id="test1">上传图片</button>
                    {/if}

                    <div id="tu-images" class="layui-upload-list"  style=" {if isset($vo.portrait) && $vo.portrait } display: block {else/} display: none{/if}"  >
                        <img data-tips-image="" class="layui-upload-img" src="{$vo.portrait|default=''}" width="100px" height="100px"  id="demo1">
                        <input hidden name="portrait" value="{$vo.portrait|default=''}"/>
                    </div>

                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">门店</label>
            <div class="layui-input-block" id="tag_ids2">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">系统组织</label>
            <div class="layui-input-block">
                <select name="department_id" lay-search required>
                    <option value="">请选择</option>
                    {foreach $departmentName as $kk => $vv}
                    <option value="{$vv.id}" {if isset($vo.department_id) and $vo.department_id eq $vv.id} selected
                            {/if}>{$vv.spl}{$vv.name}</option>
                    {/foreach}
                </select>
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input name="phone" value='{$vo.phone|default=""}' required placeholder="请输入联系电话"
                       class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">岗位</label>
            <div class="layui-input-block">
                <input name="position" value='{$vo.position|default=""}' placeholder="请输入岗位" class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">管理职务详情</label>
            <div class="layui-input-block">
                <input name="work_detail" value='{$vo.work_detail|default=""}' placeholder="请输入管理职务详情"
                       class="layui-input">
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="正常" {if !isset($vo.status)} checked{/if} {if isset($vo.status) && $vo.status==1 }checked{/if}>
                <input type="radio" name="status" value="2" title="冻结" {if isset($vo.status) && $vo.status==2 }checked{/if}>
                <input type="radio" name="status" value="3" title="离职" {if isset($vo.status) && $vo.status==3 }checked{/if}>
                <p class="help-block"></p>
            </div>
        </div>
    </div>

    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
</form>
<script>
    form.render();

</script>
<script>
    layui.config({
        base: '__ROOT__/static/plugs/layui/bin/selectMany/',
    }).extend({
        selectM: 'selectM',
    }).use(['selectM'], function () {
        var selectM = layui.selectM
            ,element = layui.element
            ,upload = layui.upload;

        //常规使用 - 普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: '{:url("uploadImg")}' //改成您自己的上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });

                element.progress('demo', '0%'); //进度条复位
                layer.msg('上传中', {icon: 16, time: 0});
            }
            ,done: function(res){
                //如果上传失败
                if(res.code != 200){
                    return layer.msg('上传失败');
                }else {
                    $('#tu-images').show();
                }
                //上传成功的一些操作
               $('input[name="portrait"]').val(res.data);
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
            //进度条
            ,progress: function(n, index, e){
                element.progress('demo', n + '%'); //可配合 layui 进度条元素使用
                if(n == 100){
                    layer.msg('上传完毕',{time: 1000});
                }
            }
        });

        var tagData =<?php if(!empty($distributor)){ echo $distributor;}else{echo '';}?>;

        //多选标签-所有配置
        var tagIns2 = selectM({
            //元素容器【必填】
            elem: '#tag_ids2'
            //候选数据【必填】
            , data: tagData
            //默认值
            , selected: [{$vo.shop_id|default=""}]
            //最多选中个数，默认5
            , max: 50
            //input的name 不设置与选择器相同(去#.)
            , name: 'shop_id'
            //值的分隔符
            , delimiter: ','
            //候选项数据的键名
            , field: {idName: 'id', titleName: 'name'}
        });
    });
</script>


